-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiPopover and parts] Converted to Emotion #5977
Conversation
Inherited panel padding/margin
Inherited panel padding/margin
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
This PR is ready for review, though it looks like CI is having a bad day. Also note to those who attended the CSS-in-JS weekly when I talked about converting EuiPOpover to HOC. After pulling out the arrow and panel elements to their own components, I no longer need access to EuiTheme directly in EuiPopover, so I was able to revert that change. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chaos. 🎉
The shadow in dark mode looks much better. I tested in Chrome, Safari, Edge, and Firefox. LGTM!
I found some minor issues. Nothing special.
<div className={classes} ref={popoverRef} {...rest}> | ||
<div className={anchorClasses} ref={this.buttonRef}> | ||
<div css={popoverStyles} className={classes} ref={popoverRef} {...rest}> | ||
<div css={{ display }} className={anchorClasses} ref={this.buttonRef}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This render as eui-docs-16vtueo-render
. Should you create a new key euiPopover__anchor
in src/components/popover/popover.styles.ts
so that it renders like eui-docs-kp09r4-euiPopover__anchor
?
const popoverAnchorStyles = [styles.euiPopover__anchor, { display }];
<div css={popoverAnchorStyles} className={anchorClasses} ref={this.buttonRef}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth with myself on this one because the only css
applied to this element is the display
styles which are passed directly so styles.euiPopover__anchor
wouldn't contain anything and would just be repeating euiPopover__anchor
which we have to keep as a static class name of simply .euiPopover__anchor
anyway.
Basically keeping to our "pattern" here just adds extra unused cruft.
// If a paddingSize is not directly provided, inherit from the EuiPopoverPanel | ||
paddingStyles[paddingSize || panelPadding], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea! 💡
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
The |
Still unsure of the cause, but almost more confused now because 1)
@constancecchen Does anything here sound familiar with your recent focus fighting work? |
@thompsongl super apologies for taking so long to get back to this - bizarrely enough EDIT: To add even more to the weirdness, this passed locally for me when I ran |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
This is the only rational explanation I can think of - Emotion is causing a few more rerender loops which is somehow triggering this change. FWIW, I'm testing this locally with the I think what's happening is actually due to react-focus-on's autoFocus behavior. If I set EuiFocusTrap's I think the best way forward frankly (after #5784) is to remove
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5977/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! The change to initialFocus
makes it so that all functionality appears unchanged.
const classes = classNames( | ||
'euiComboBoxOptionsList', | ||
'euiPopover__panel', | ||
'euiPopover__panel-isAttached', | ||
'euiPopover__panel-noArrow', | ||
'euiPopover__panel-isOpen', | ||
`euiPopover__panel--${position}` | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent refactor!
* Upgrade to v62.0.3 * Update EUI i18n tokens * Update html string snapshots - Emotion CSS hash changed * [EuiIcon] Update instances of `keyboardShortcut` icons to `keyboard` * [EuiErrorBoundary] Update snapshots from Emotion conversion * [EuiImage] Update snapshots, tests, and CSS to account for Emotion conversion * [EuiImage][RTL] Fix test failures caused by EuiImage changes * [EuiCommentList] Deprecate EuiCommentProps.type * [EuiCommentList] Rename `timelineIcon` prop to `timelineAvatar` - see elastic/eui#6071 * [EuiCommentList] Fix selectors deprecated by Emotion conversion * [EuiPopover][EuiCommentEvent][Enzyme] Fix mounted test failures caused by Emotion conversions - Mounting displays the Emotion wrapper with the data-test-subj on them - we need to specify the output div renders in order for text assertions to be correct * [EuiPopover] Deprecate `initialFocus={false}` as an option see elastic/eui#6044 * [EuiPopover] Rename `display=inlineBlock` to `inline-block` - see elastic/eui#5977 * [EuiPopover] Update snapshots from Emotion conversion * [EuiPopover] Replace deprecated `.euiPopover__panel-isOpen` class with new `[data-popover-open]` attribute * [EuiPopover][RTL] Fix test failures caused by not waiting for EuiPopover animation/transition * Skip failing a11y tests - test w/ similar error already skipped in another test above - requires closing the popover for next test to pass - not sure why delete action is no longer available * Fix failing Security Cypress tests * Attempt to squash flaky FTR tests around Add Filter popover Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Jonathan Budzenski <[email protected]>
* Upgrade to v62.0.3 * Update EUI i18n tokens * Update html string snapshots - Emotion CSS hash changed * [EuiIcon] Update instances of `keyboardShortcut` icons to `keyboard` * [EuiErrorBoundary] Update snapshots from Emotion conversion * [EuiImage] Update snapshots, tests, and CSS to account for Emotion conversion * [EuiImage][RTL] Fix test failures caused by EuiImage changes * [EuiCommentList] Deprecate EuiCommentProps.type * [EuiCommentList] Rename `timelineIcon` prop to `timelineAvatar` - see elastic/eui#6071 * [EuiCommentList] Fix selectors deprecated by Emotion conversion * [EuiPopover][EuiCommentEvent][Enzyme] Fix mounted test failures caused by Emotion conversions - Mounting displays the Emotion wrapper with the data-test-subj on them - we need to specify the output div renders in order for text assertions to be correct * [EuiPopover] Deprecate `initialFocus={false}` as an option see elastic/eui#6044 * [EuiPopover] Rename `display=inlineBlock` to `inline-block` - see elastic/eui#5977 * [EuiPopover] Update snapshots from Emotion conversion * [EuiPopover] Replace deprecated `.euiPopover__panel-isOpen` class with new `[data-popover-open]` attribute * [EuiPopover][RTL] Fix test failures caused by not waiting for EuiPopover animation/transition * Skip failing a11y tests - test w/ similar error already skipped in another test above - requires closing the popover for next test to pass - not sure why delete action is no longer available * Fix failing Security Cypress tests * Attempt to squash flaky FTR tests around Add Filter popover Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Jonathan Budzenski <[email protected]>
[Breaking] EuiPopover's
display
prop now accepts real CSSdisplay
valuesThe reason this is breaking is because the old value
inlineBlock
needed to change to snake caseinline-block
. This shouldn't be a big deal sinceinline-block
is default.[New] EuiPopoverPanel (internal only)
Some other EUI components were duplicating the
.euiPopover__panel
classes on EuiPanel instances to recreate the popover styles. Instead, I've pulled that EuiPanel out of EuiPopover directly and created EuiPopovePanel that other components like EuiComboBox now use. It mainly handles the styling based onposition
,isOpen
, orisAttached
.Added
EuiPopoverPanelContext
to pass throughpanelPadding
The popover title and footer components used a complicated set of parent/child selectors to inherit padding and/or create margins to account for panel padding. Instead of sticking with the nested selectors, I opted for creating a context that the EuiPopoverTitle and Footer components used to decide how it should handle those margins and it's own padding size.
This is debatable whether context here is really necessary, so I'm open to other options that don't require going back to nested selectors.
Other changes of note from the old
.euiPopover__panel
.euiPopover__panel
instead of.euiPopoverPanel
mainly to reduce breaks..euiPopover__panel-isOpen
class in favor of using a data attribute that exists or doesn't calleddata-popover-open
.[New] EuiPopoverArrow (internal only)
This new component mainly handles the styling based on
arrowPosition
. The styles for this element used to be a complicated set of multiple pseudo elements, borders, and clip-paths. I've reduced this complexity to a single:before
element with borders to create the triangle and then using thefilter: drop-shadow()
method of creating the shadow on the whole panel. Usingfilter
takes into account the actual outline of an element where asbox-shadow
is only ever square.[New]
property
option foreuiShadowMedium()
In order to quickly support the same values for this shadow size in both methods, I just added the property as an optional key in the optional parameter.
[New] JS mixin for
euiFormMaxWidth
I needed this in order to re-use the variable in JS. I decided not to put it in the global theme at least for now and push the decision down the road on how we want to handle component-based re-usable variables.
[New]
logicalSizeCSS(width, height)
For quickly creating
width
andheight
values.[Update] Increased the opacity of shadow color in dark mode
It's always been pretty hard to see the outlines of panels with just a simple shadow, this helps a little bit, but I think we can follow up at some point with something even better.
[Conversion] EuiPopover & parts
fullWidth=false
).Checklist